<style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
</style>

<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form layuimini-form">


            <div class="layui-form-item">
                <label class="layui-form-label required">新的密码</label>
                <div class="layui-input-block">
                    <input autocomplete="off" type="password" name="password" lay-verify="required" lay-reqtext="新的密码不能为空" placeholder="请输入新的密码"  value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">新的密码</label>
                <div class="layui-input-block">
                    <input autocomplete="off" type="password" name="again_password" lay-verify="required|confirm_password" lay-reqtext="新的密码不能为空" placeholder="请输入新的密码"  value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['form','miniTab','jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            miniTab = layui.miniTab;
        var $ = layui.jquery;
        form.verify({
            confirm_password:function(value){
                if($('input[name=password]').val() !== value)
                    return '两次密码输入不一致！';
            }
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var post_data = data.field;
            $.post('{:url("admin/user_password")}',post_data,function (res){
                if(res.code==0){
                    var index = layer.msg('修改成功',{icon: 1}, function () {
                        layer.close(index);
                        miniTab.deleteCurrentByIframe();
                    });
                }else{
                    layer.msg(res.msg,{icon: 2}, function () {
                    });
                }
            });
            return false;
        });

    });
</script>
</body>
</html>